package com.bootdo.common.utils;

import java.util.HashMap;
import java.util.Map;

public class AppR extends HashMap<String, Object> {
    private static final long serialVersionUID = 1L;

    public AppR() {
        put("code", 200);
        put("msg", "操作成功");
    }

    public static AppR error() {
        return error(1, "操作失败");
    }

    public static AppR error(String msg) {
        return error(500, msg);
    }

    public static AppR error(int code, String msg) {
        AppR r = new AppR();
        r.put("code", code);
        r.put("msg", msg);
        r.put("data"," 1");
        return r;
    }

    public static AppR ok(String msg) {
        AppR r = new AppR();
        r.put("msg", msg);
        r.put("data","[]");
        return r;
    }



    public static AppR ok() {
        return new AppR();
    }
    public static AppR ok(Object o) {
        AppR r = new AppR();
        r.put("code",200);
        r.put("msg","成功");
        r.put("data",o);
        return r;
    }

    @Override
    public AppR put(String key, Object value) {
        super.put(key, value);
        return this;
    }
}
